import expressionDataUpShowLabel from '/src/static/analysisData/exp_limma_Up_showLabel.json';
import expressionDataUpNoLabel from '/src/static/analysisData/exp_limma_Up_noLabel.json';
import expressionDataNoShowLabel from '/src/static/analysisData/exp_limma_No_showLabel.json';
import expressionDataNoNoLabel from '/src/static/analysisData/exp_limma_No_noLabel.json';
import expressionDataDownShowLabel from '/src/static/analysisData/exp_limma_Down_showLabel.json';
import expressionDataDownNoLabel from '/src/static/analysisData/exp_limma_Down_noLabel.json';

import { createScatterSeries, formatDecimal } from './utils';


const expLimmaOption = {
    tooltip: {
        trigger: 'item',
        formatter: function (params: { value: string[]; }) {
            return 'Expression: ' + params.value[3] +
                '<br>TumorType: ' + params.value[4] + 
                '<br>P.Value_Single: ' + formatDecimal('', '', params.value[5]) +
                '<br>P.Value_Pancancer: ' + formatDecimal('', '', params.value[6]) + 
                '<br>logFC_Single: ' + formatDecimal('', '', params.value[7]) +
                '<br>logFC_Pancancer: ' + formatDecimal('', '', params.value[8]);          
        }
    },
    legend: {
        data: ['Up', 'Down', 'No'],  // 图例名称
        orient: 'vertical',
        left: 'right',       // 放置在容器的右侧
        top: 'middle',       // 垂直居中
        align: 'left'  
    },
    xAxis: {
        type: 'value',
        name: 'p−value (most significant tumor type)',
        nameLocation: 'middle',  // Positioning the name in the middle of the axis
        nameTextStyle: {
            padding: [5, 0, 0, 0],  // Adjust padding to bring the name closer to the axis
            fontSize: 24,
            color: 'black',
            align: 'center',  // Aligns the name text to the right side (closer to the axis line)
        },
        splitLine: {
            show: false  // 隐藏 x 轴的网格线
        },
        axisLine: {
            show: true,
            lineStyle: {
                color: 'black', // 设置坐标轴颜色
                width: 2 // 设置坐标轴宽度
            }
        },
        axisLabel: {
            formatter: function (value: any) {
                // Apply inverse transformation for display

                let transformedValue = Math.pow(10, -value)
                if (transformedValue < 1e-4) {
                    return transformedValue.toExponential(1); // 保留两位小数的科学计数法
                }
                return transformedValue > 1e-5 ? transformedValue : 0;
            },
            customValues: [0, 3,  6, 9, 12, 15, 18]
        },
        // boundaryGap: [0, 0.1],
        // min: 'dataMin',  
        // max: 'dataMax',
    },
    yAxis: {
        type: 'value',
        name: 'p−value (Pancancer cohort)',
        nameLocation: 'middle',
        nameTextStyle: {
            padding: [5, 0, 35, 0],  
            fontSize: 24,
            color: 'black',
            align: 'center',  
        },
        splitLine: {
            show: false  // 隐藏 x 轴的网格线
        },
        axisLabel: {
            formatter: function (value:any) {
                // Apply inverse transformation for display
                let transformedValue = Math.pow(10, -value + 1)
                if (transformedValue < 1e-4) {
                    return transformedValue.toExponential(1); // 保留两位小数的科学计数法
                }
                return transformedValue > 0.00001 ? transformedValue : 0;
            },
            customValues: [1, 3, 6, 9, 12, 15, 18]
        },
        axisLine: {
            show: true,
            lineStyle: {
                color: 'black', // 设置坐标轴颜色
                width: 2 // 设置坐标轴宽度
            },
        },
        boundaryGap: false,
        // min: 0,
        // max: 12,
        // interval: 2
    },
    color: ['#E41A1C', '#377EB8', '#BFBFBF'],
    series: [
        createScatterSeries(expressionDataDownNoLabel, 'Down', 'Down', '#377EB8', 'exp', true),
        createScatterSeries(expressionDataDownShowLabel, 'Down', 'Down', '#377EB8', 'exp', false), 
        createScatterSeries(expressionDataUpNoLabel, 'Up', 'Up', '#E41A1C', 'exp', true),
        createScatterSeries(expressionDataUpShowLabel, 'Up', 'Up', '#E41A1C', 'exp', false),
        createScatterSeries(expressionDataNoNoLabel, 'No', 'No', '#BFBFBF', 'exp', true),
        createScatterSeries(expressionDataNoShowLabel, 'No', 'No', '#BFBFBF', 'exp', false)
    ]
};

export default expLimmaOption